﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.SignalR;

namespace PMRC.API.Hubs
{
    [Authorize]
    public class ChatHub : Hub
    {
        private readonly ILogger<ChatHub> _logger;

        public ChatHub(ILogger<ChatHub> logger)
        {
            _logger = logger;
        }


        public async Task SendMessage(string message)
        {
            string connectionId = Context.ConnectionId; // 获取当前客户端的 ConnectionId/ClientId

            // 向当前客户端发送消息
            await Clients.Client(connectionId).SendAsync("ReceiveMessage", message);
        }
    }
}
